// HSS.Logging.Management.InstallWizard.cs
// ----------------------------------------------------------------------------
// Licensed under the MIT license
// http://www.opensource.org/licenses/mit-license.html
// ----------------------------------------------------------------------------
// HighSpeed-Solutions, LLC
// Copyright (c) 2001-2010
// ----------------------------------------------------------------------------
// File:       InstallWizard.cs
// Author:     HSS\gbanta
// Created:    08/12/2010
// Modified:   12/04/2010
// ----------------------------------------------------------------------------
namespace HSS.Logging.Management
{
	#region Using Directives
	using System;
	using System.ComponentModel;
	using System.Drawing;
	using System.Windows.Forms;
	using HSS.Forms;
	using HSS.Data;
	#endregion

	#region InstallWizard
	internal sealed class InstallWizard : WizardForm
	{
		internal static WizardAction Action = WizardAction.None;
		internal static string ConnectionString = null;
		internal static string Database = null;
		internal static Exception Error = null;
		internal static string Server = string.Empty;
		internal static string User = string.Empty;
		internal static string Pwd = string.Empty;
		internal static bool Trusted = false;
		internal static bool DatabaseExists;

		public InstallWizard()
		{
			this.InitializeComponent();
			base.SetPanels(new WizardPanel[] { new WelcomePanel(), new OptionsPanel(), new ServerDatabasePanel(), new ConfirmPanel(), new ResultPanel() });
		}
		public InstallWizard(bool Install)
		{
			this.InitializeComponent();
			Action = Install ? WizardAction.AddAllFeatures : WizardAction.RemoveAllFeatures;
			base.SetPanels(new WizardPanel[] { new ServerDatabasePanel(), new ConfirmPanel(), new ResultPanel() });
		}
		public InstallWizard(bool Install, string connnectionString)
		{
			this.InitializeComponent();
			Action = Install ? WizardAction.AddAllFeatures : WizardAction.RemoveAllFeatures;
			ConnectionString = connnectionString;
			DataAccessConnection dac = new DataAccessConnection(ConnectionString);
			Server = dac.DataSource;
			Database = dac.InitialCatalog;
			User = dac.UserID;
			Pwd = dac.Password;
			Trusted = dac.IntegratedSecurity;
			dac = null;
			base.SetPanels(new WizardPanel[] { new ServerDatabasePanel(), new ConfirmPanel(), new ResultPanel() });
		}

		private void InitializeComponent()
		{

			base.Glyph = HSS.Logging.Management.Resources.coremgmtbmp;
			base.Icon = HSS.Logging.Management.Resources.SqlInstaller;
			base.SuspendLayout();
			new ComponentResourceManager(typeof(InstallWizard)).ApplyResources(this, "$this");
			base.AutoScaleMode = AutoScaleMode.Font;
			base.Name = "InstallWizard";
			base.ShowIcon = true;
			base.ResumeLayout(false);
		}

		protected override void OnInitialActivated(EventArgs e)
		{
			base.OnInitialActivated(e);
			base.NextButton.Focus();
		}

		internal static DialogResult ShowRTLSafeMessageBox(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
		{
			MessageBoxOptions options = 0;
			if (IsRTLResources)
			{
				options |= MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign;
			}
			return MessageBox.Show(text, caption, buttons, icon, MessageBoxDefaultButton.Button1, options);
		}

		internal static bool IsRTLResources
		{
			get { return false; }
		}
	}
	#endregion
}